﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace WPGame.BaseObject
{
    enum DIR
    {
        NONE = 0,
        UP = 1,
        RIGHT = 2,
        DOWN = 3,
        LEFT = 4,
    };

    class MoveAbillity
    {
        private float m_fSpeed;
        private Vector2 m_Speed;
        private DIR m_Direction;

        public MoveAbillity()
        {
            m_fSpeed = 0.0f;
            m_Direction = DIR.NONE;
            VSpeed = SpeedVector();
        }
        public MoveAbillity(float _fspeed, DIR _dir)
        {
            m_fSpeed = _fspeed;
            m_Direction = _dir;
            VSpeed = SpeedVector();
        }

        private Vector2 SpeedVector()
        {
            switch (Direction)
            {
                case DIR.UP:
                    return -m_fSpeed * Vector2.UnitY;
                case DIR.DOWN:
                    return m_fSpeed * Vector2.UnitY;
                case DIR.RIGHT:
                    return m_fSpeed * Vector2.UnitX;
                case DIR.LEFT:
                    return -m_fSpeed * Vector2.UnitX;
                case DIR.NONE:
                    return Vector2.Zero;
                default:
                    return Vector2.Zero;
            }
        }

        public Vector2 VSpeed
        {
            get { return m_Speed; }
            private set { m_Speed = value; }
        }

        public float fSpeed
        {
            get { return m_fSpeed; }
            set
            {
                m_fSpeed = value;
                VSpeed = SpeedVector();
            }
        }

        /// <summary>
        /// Hướng di chuyển
        /// </summary>
        public DIR Direction
        {
            get { return m_Direction; }
            set
            {
                m_Direction = value;

                VSpeed = SpeedVector();

            }
        }

    }

}
